package com.xdtech.hotel.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.sql.Timestamp;

import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.hotel.model.Device;

import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2015-04-04 11:06:39
 * @since 1.0
 * @see
 */
public class DeviceItem extends BaseItem implements Serializable{
	private static final long serialVersionUID = 1L;
	private Long id;
	@GridColumn(title="设备序列号",width=100)
	private String sn;
	@GridColumn(title="设备IP地址",width=100)
	private String ip;
	@GridColumn(title="设备名称",width=100)
	private String name;
	@GridColumn(title="通信端口",width=100)
	private String port;

	public void setId(Long id) {
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	
	public void setSn(String sn) {
		this.sn = sn;
		addQuerys("sn", sn);
	}
	public String getSn() {
		return sn;
	}
	
	public void setIp(String ip) {
		this.ip = ip;
		addQuerys("ip", ip);
	}
	public String getIp() {
		return ip;
	}
	
	public void setName(String name) {
		this.name = name;
		addQuerys("name", name);
	}
	public String getName() {
		return name;
	}
	
	public void setPort(String port) {
		this.port = port;
		addQuerys("port", port);
	}
	public String getPort() {
		return port;
	}
	
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static DeviceItem createItem(Device device) {
		DeviceItem deviceItem = new DeviceItem();
		BeanUtils.copyProperties(deviceItem, device);
		//自定义属性设置填充
		return deviceItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<DeviceItem> createItems(List<Device> devices) {
		List<DeviceItem> deviceItems = new ArrayList<DeviceItem>();
		for (Device device : devices) {
			deviceItems.add(createItem(device));
		}
		return deviceItems;
	}
}
